#include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define pi pair<int,int>
using namespace std;
const int N=2e5+10;
int n,m,st;
bool flag;
pi ans[N];
void add(int x,int y,int lx,int ly)
{
    for(int i=x;i<=lx-(lx-x==ly-y);i+=2)
        ans[++st]=mk(i,y),ans[++st]=mk(i,ly);
    for(int i=y+(lx-x)/2+2;i<=ly-(lx-x)/2-2;i+=2) ans[++st]=mk((x+lx)/2,i);
}
int main()
{
    freopen("bishop.in","r",stdin);
    freopen("bishop.out","w",stdout);
    scanf("%d%d",&n,&m);
    if(n>m) flag=1,swap(n,m);
    add(1,1,n-!(n&1),m-!(m&1));
    add(2,1,n-(n&1),m-!(m&1));
    printf("%d\n",st);
    for(int i=1;i<=st;i++)
    {
        if(flag) swap(ans[i].fi,ans[i].se);
        printf("%d %d\n",ans[i].fi,ans[i].se);
    }
    return 0;
}